Bin packing problem

In computational complexity theory, the bin packing problem is a combinatorial NP-hard problem. In it, objects of different volumes must be packed into a finite number of bins of capacity V in a way that minimizes the number of bins used.

There are many variations of this problem, such as 2D packing, linear packing, packing by weight, packing by cost, and so on. They have many applications, such as filling up containers, loading trucks with weight capacity, creating file backup in removable media and technology mapping in Field-programmable gate array semiconductor chip design.

The bin packing problem can also be seen as a special case of the cutting stock problem. When the number of bins is restricted to 1 and each item is characterised by both a volume and a value, the problem of maximising the value of items that can fit in the bin is known as the knapsack problem.

Despite the fact that it is NP-hard, optimal solutions to very large instances can be produced with sophisticated algorithms. In addition, many heuristics have been developed: for example, the first fit algorithm provides a fast but often non-optimal solution, involving placing each item into the first bin in which it will fit. It requires Θ(n log n) time, where n is the number of elements to be packed. The algorithm can be made much more effective by first sorting the list of elements into decreasing order (sometimes known as the first-fit decreasing algorithm), although this still does not guarantee an optimal solution, and for longer lists may increase the running time of the algorithm. It is known, however, that there always exists at least one ordering of items that allows first-fit to produce an optimal solution (Lewis, 2009).

Contents

Formal statement

Given a bin size V and a list a_1,\dots,a_n of sizes of the items to pack, find an integer B and a B-partition S_1 \cup \dots \cup S_B of \{1,\dots,n\} such that \sum_{i \in S_k} a_i \leq V for all k=1,\dots,B.

A solution is optimal if it has minimal B. The B-value for an optimal solution is denoted OPT below.

First-fit algorithm

This is a very straightforward greedy approximation algorithm. The algorithm processes the items in arbitrary order. For each item, it attempts to place the item in the first bin that can accommodate the item. If no bin is found, it opens a new bin and puts the item within the new bin.

It is rather simple to show this algorithm achieves an approximation factor of 2. This is due to the observation that at any given time, it is impossible for 2 bins to be at most half full. The reason is that if at some point a bin was at most half full, meaning it has at least a space of V / 2, the algorithm will not open a new bin for any item whose size is at most V / 2. Only after the bin fills with more than V / 2 or if an item with a size larger than V / 2 arrives, the algorithm may open a new bin.

Thus if we have B bins, at least B − 1 bins are more than half full. Therefore \sum_{i=1}^n a_i>\tfrac{B-1}{2}V. Because \tfrac{\sum_{i=1}^n a_i}{V} is a lower bound of the optimum value OPT, we get that B − 1 < 2OPT and therefore B ≤ 2OPT.[1] See analysis below for better approximation results.

Sample algorithm

binpackFFd(S,n,bin)
    float[] used = new float[n + 1];
    //used[j] is the amount of space in bin j already used up.
    int i, j;
    Initialize all used entries to 0.0
    Sort S into descending(nonincreasing)order, giving the sequence S1 >= S2 >= ... >= Sn.
    for(i = 1; i <= n; i++)
      //Look for a bin in which s[i] fits.
      for(j = 1; j <= n; j++)
       if (used[j]+si<+1.0)
         bin[i] = j;
         used[j] += si;
         break;  //exit for(j)
      //continue for(i).

[1]

Analysis of approximate algorithms

The best fit decreasing and first fit decreasing strategies are among the simplest heuristic algorithms for solving the bin packing problem. They have been shown to use no more than 11/9 OPT + 1 bins (where OPT is the number of bins given by the optimal solution).[2] The simpler of these, the First Fit Decreasing (FFD) strategy, operates by first sorting the items to be inserted in decreasing order by volume, and then inserting each item into the first bin in the list with sufficient remaining space. Without the sorting step, we only achieve the looser bound of 17/10 OPT + 2. Sometimes, however, one does not have the option to sort the input, for example, when faced with an online bin packing problem. In 2007, it was proved that the bound 11/9 OPT + 6/9 for FFD is tight.[3] MFFD[4] (a variant of FFD) uses no more than 71/60 OPT + 1 bins[5] (i.e. bounded by about 1.18×opt, compared to about 1.22×opt for FFD). In 2010, an upper bound for the asymptotic performance ratio was decreased to 17/10 OPT + 7/10 for FF and for the absolute performance ratio - to 12/7 OPT.[6]

For all ε > 0, Bin Packing is hard to approximate within 3/2 - ε. If such approximation exists, one could partition n non-negative numbers into two sets with the same sum in polynomial time. However, this problem is also known to be NP-hard. It is therefore impossible to propose a polynomial-time approximation scheme (PTAS) to the bin packing problem. Alternatively, it is possible to find a solution for any 0 < ε ≤ 1/2 in polynomial time using at most (1 + 2ε)OPT + 1 bins. This approximation type is known as asymptotic PTAS.[7][8]

See also

Notes

  1. ^ Vazirani 2003, p. 74.
  2. ^ Yue 1991, pp. 321–331.
  3. ^ Dósa 2007, pp. 1–11.
  4. ^ Garey & Johnson 1985, pp. 65–106.
  5. ^ Yue & Zhang 1995, pp. 318–330.
  6. ^ Xia & Tan 2010, pp. 1–8.
  7. ^ Vazirani 2003, pp. 74–76.
  8. ^ de la Vega & Lueker 1981, pp. 349–355.

References

External links